﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using SOM.AbstractDALFactory;
using SOM.ConcreteDALFactory;
using SOM.ConcreteDAL;

public partial class Administracao_InstituicoesAdm : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            CarregarGrid();
        }

        if (Request["__EVENTARGUMENT"] != null && Request["__EVENTARGUMENT"].ToString() != string.Empty)
        {
            ExcluirInstituicao(int.Parse(Request["__EVENTARGUMENT"]));
        }

    }

    private void ExcluirInstituicao(int idInstituicao)
    {
        throw new NotImplementedException();
    }
    protected void btnSalvar_Click(object sender, EventArgs e)
    {

    }
    protected void btnCancelar_Click(object sender, EventArgs e)
    {

    }
    protected void grvInstituicoesRowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            HyperLink hlkExcluirReclamacao = (HyperLink)e.Row.FindControl("hlkExcluirInstituicao");
            hlkExcluirReclamacao.NavigateUrl = "javascript:ExcluirInstituicao('" + e.Row.Cells[0].Text + "')";
        }
    }

    private void CarregarGrid()
    {

        SOMAbstractDALFactory factory = new SOMConcreteDALFactory();
        InstituicaoDAL instituicaoDAL = factory.CreateInstituicaoDAL();

        grvInstituicoes.DataSource = instituicaoDAL.FindAll();
        frmInstituicoes.DataBind();
    }
}
